package cn.xiuxian.util;



import com.alibaba.druid.pool.DruidDataSource;


import java.sql.Connection;
import java.sql.SQLException;

public class PoolUtils {

    public   static DruidDataSource basicDataSource  = new DruidDataSource();

    static {
        basicDataSource.setUrl(DbConfigUtil.getValue("url"));
        basicDataSource.setUsername(DbConfigUtil.getValue("username"));
        basicDataSource.setPassword(DbConfigUtil.getValue("password"));
        basicDataSource.setInitialSize(Integer.valueOf(DbConfigUtil.getValue("initialSize")));
        basicDataSource.setMaxActive(Integer.valueOf(DbConfigUtil.getValue("maxActive")));

        basicDataSource.setMaxIdle(Integer.valueOf(DbConfigUtil.getValue("maxIdle")));
        basicDataSource.setMinIdle(Integer.valueOf(DbConfigUtil.getValue("minIdle")));
        basicDataSource.setMaxWait(Long.valueOf(DbConfigUtil.getValue("maxWait")));

    }

    public  static Connection getConnection() throws SQLException {
        return basicDataSource.getConnection();
    }

}
